#include "GlfwWindow.h"
#include "ShaderProgram.h"
#include "TargetCube.h"
#include "Texture2D.h"
#include "VertexArray.h"
#include <iostream>
using namespace std;

int main(int argc, char *argv[])
{
    GlfwWindowManager window(1200, 900);
    if (!window.initWindow("LearnOpenGL")) {
        std::cout << "Failed to create GLFW window" << std::endl;
    }

    std::vector<TargetCube> cubes;
    std::vector<glm::vec3>  positions;
    std::vector<glm::vec3>  scales;
    for (int i = 0; i < 100; i++) {
        TargetCube cube;
        cubes.push_back(cube);
        positions.push_back(glm::vec3((i % 10) * 1.f, -int(i / 10) * 1.f, 0.f));
        scales.push_back(glm::vec3(1.f, 0.5f, 0.5f));
    }

    for (int i = 0; i < cubes.size(); i++) {
        cubes[i].setPosition(positions[i]);
        cubes[i].setScale(scales[i]);
        cubes[i].setRotate(glm::vec3(0, 0.f, 45.f));
    }

    glEnable(GL_DEPTH_TEST);
    glClearColor(0.2f, 0.2f, 0.3f, 1.0f);
    window.loopRender([&]() {
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

        glm::mat4 proj = window.getProj();
        glm::mat4 view = window.getView();

        for (int i = 0; i < cubes.size(); i++) {
            cubes[i].render(view, proj);
        }
    });

    return 0;
}